package com.GlobalPaint.app.ui.Mine;

import android.app.Dialog;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.GlobalPaint.app.Adapter.MyFensiAdapter;
import com.GlobalPaint.app.R;
import com.GlobalPaint.app.bean.MyFriendBean;
import com.jcodecraeer.xrecyclerview.XRecyclerView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MyFensiActivity extends AppCompatActivity {

    @BindView(R.id.iv_goback)
    ImageView ivGoback;
    @BindView(R.id.tv_common_center)
    TextView tvCommonCenter;
    @BindView(R.id.xrecycler)
    XRecyclerView xrecycler;
    private MyFensiAdapter adapter;
    private MyFriendBean bean;
    private LinearLayoutManager linearLayoutManager;
    private int page;
    private Dialog dlgWaiting2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_fensi);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        tvCommonCenter.setText("我的粉丝");
        linearLayoutManager = new LinearLayoutManager(MyFensiActivity.this);
        xrecycler.setLayoutManager(linearLayoutManager);
        xrecycler.setLoadingMoreEnabled(false);
        //getguanzhu();
       // initLoad();
    }
   /* private void getguanzhu() {
        dlgWaiting2 = DialogWaiting.createDialogWaiting(MyFensiActivity.this, "加载中......");
        dlgWaiting2.show();
        String url= Constants.JASON_SERVICE_URL+"/renren-security/appapi/appFriends/getIdols?userName="+ DataManager.userEntity.getUserName();
        DataManager.getInst().getHttpRequestJsonClass(url, DataManager.userEntity.getCookie(), MyFriendBean.class, new DataManager.Callback() {
            @Override
            public void onSuccess(Object o) {
                dlgWaiting2.cancel();
                bean=(MyFriendBean)o;
                if (bean.getStatus() == 1){
                    if(bean.getData() != null && bean.getData().size()>0){
                        adapter=new MyFensiAdapter(bean.getData());
                        xrecycler.setAdapter(adapter);
                        adapter.notifyDataSetChanged();
                    }
                }
                else {
                    Toast.makeText(MyFensiActivity.this,bean.getMsg(),Toast.LENGTH_LONG).show();
                }
                xrecycler.refreshComplete();
            }

            @Override
            public void onFailure(ReturnStatusResultEntity error) {
                dlgWaiting2.cancel();
                if(bean !=null){
                    if(bean.getData() != null && bean.getData().size()>0) {
                        bean.getData().clear();
                        Toast.makeText(MyFensiActivity.this, bean.getMsg(), Toast.LENGTH_LONG).show();
                        adapter.notifyDataSetChanged();
                        xrecycler.refreshComplete();
                    }
                }

            }
        });
        dlgWaiting2.cancel();
    }*/
   /* private void initLoad() {
        xrecycler.setLoadingListener(new XRecyclerView.LoadingListener() {
            @Override
            public void onRefresh() {
                String url= Constants.JASON_SERVICE_URL+"/renren-security/appapi/appFriends/getIdols?userName="+ DataManager.userEntity.getUserName();
                DataManager.getInst().getHttpRequestJsonClass(url, DataManager.userEntity.getCookie(), MyFriendBean.class, new DataManager.Callback() {
                    @Override
                    public void onSuccess(Object o) {
                        page = 1;
                        MyFriendBean talentBean=(MyFriendBean)o;
                        if( bean.getStatus() == 1){
                            if (bean.getData() != null && bean.getData().size()>0){
                                bean.getData().clear();
                                bean.getData().addAll(talentBean.getData());
                                adapter.notifyDataSetChanged();
                                xrecycler.loadMoreComplete();
                            }else {
                                Toast.makeText(MyFensiActivity.this,"刷新失败",Toast.LENGTH_LONG).show();
                            }
                        }
                        else {
                            Toast.makeText(MyFensiActivity.this,bean.getMsg(),Toast.LENGTH_LONG).show();
                        }
                        xrecycler.refreshComplete();
                    }

                    @Override
                    public void onFailure(ReturnStatusResultEntity error) {
                        xrecycler.refreshComplete();
                    }
                });
            }

            @Override
            public void onLoadMore() {

            }
        });
    }*/
    @OnClick(R.id.iv_goback)
    public void onViewClicked(View view) {
        switch (view.getId()){
            case R.id.iv_goback:
                finish();
                break;
        }
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
